<!doctype html>
<html class="no-js" lang="en">
<!--<![endif]-->
<head>
<meta name="layout" content="common">
<title>Manage Redemption</title>

<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.8.2/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="${resource(dir:'css', file:'demo_table.css') }">
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.8.2/jquery.dataTables.min.js"></script>
</head>
<body id="body">
	<h2>Manage Redemption</h2>
	<hr />

	<g:if test="${flash.message}">
		<div class="alert alert-success">
			<img src="${resource(dir:'images', file:'icon_successful.png') }" />&nbsp;&nbsp;${flash.message}
		</div>
	</g:if>
	<div class="row>">
		<g:form name="rdmptList" method="POST" action="index">
		<table width="100%">
			<tr>
				<td width="25%">Redemption Date</td>
				
				<td><div class="input-append date pull-left" id="datepicker" data-date="${new Date()}" data-date-format="yyyy-mm-dd">
						<input class="span2" type="text" name="searchRedmptDate" value="${searchRedmptDate}" readonly>
						<span class="add-on" style="height: 30px;"><i class="icon-calendar"></i></span>
					</div></td>
			</tr>
			<tr>
				<td>Status</td>
				<td>
					<g:select name="searchStatus" from="${com.mastercard.labs.Redemption.Status.values()}" optionKey="value" optionValue="key" value="${searchStatus}" noSelection="${['':'Select One...']}"/>
				</td>
			</tr>
			<tr>
				<td></td>
				<td>
					<g:actionSubmit action="search" value="Search" class="btn btn-primary" />
					<input type="button" value="Reset" class="btn btn-primary" onClick="javascript:this.form.searchRedmptDate.value='';this.form.searchStatus.value='';" />
				</td>
			</tr>
		</table>
		<br/><br/>
		
		<g:if test="${searchInd=='true'}">
		<table cellpadding="0" cellspacing="0" border="0" class="display" width="95%" id="redmptList">
			<thead>
				<tr>
					<td width="2%"><b>Tick</b></td>
					<td width="5%"><b>SN</b></td>
					<td width="20%"><b>Title</b></td>
					<td width="5%"><b>Point</b></td>
					<td width="10%"><b>Redemption Date</b></td>
					<td width="10%"><b>Image</b></td>
					<td width="5%"><b>Total Quantity</b></td>
					<td ><b>User Name</b></td>
				</tr>
			</thead>
			<tbody>
				<g:each in="${instanceList}" var="rdmp" status="stat">
					<tr class="gradeA" id="transaction-row-${rdmp.voucher?.title }">
						<g:if test="${com.mastercard.labs.Redemption.Status.SUCCESS.value == rdmp.status}">
							<td><g:checkBox name="rdmpCheckList" value="${rdmp.id}" disabled="true" checked="true"/></td>
						</g:if>
						<g:else>
							<td><g:checkBox name="rdmpCheckList" value="${rdmp.id}" checked="false" /></td>
						</g:else>
						<td>${stat + 1}</td>
						<td><g:link action="edit" id="${rdmp.id}" params="[searchTitle: searchTitle, searchMerchant: searchMerchant, searchCategories: searchCategories]">${fieldValue(bean: rdmp.voucher, field: "title")}</g:link></td>
						<td>${fieldValue(bean: rdmp.voucher, field: "rdptPoint")}</td>
						<td>${rdmp.rdptDate?.format("yyyy-MM-dd")}</td>
						<td><g:img uri="${fieldValue(bean: rdmp.voucher, field: "imageUrl")}" height="30" width="30" /></td>
						<td>${fieldValue(bean: rdmp.voucher, field: "totalQuantity")}</td>
						<td>${fieldValue(bean: rdmp.user, field: "username")}</td>
					</tr>
				</g:each>
			</tbody>
		</table>
		<g:if test="${instanceList==null ||instanceList.size==0}">
				No Record Found!
				</g:if>
				<g:else>
				<g:actionSubmit action="update" value="Update" class="btn btn-primary" />
				</g:else>
		</g:if>
		</g:form>
	</div>
	<br/>
	<script src="${resource(dir:'js/app', file:'user_search.js') }"></script>
</body>
</html>